<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/init.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<jsp:include page="/WEB-INF/jsp/common/common.jsp" />
	<jsp:include page="/WEB-INF/jsp_lib/validate.jsp" />
	<link rel="stylesheet" href="${path}/style_lib/zTree_v3/css/zTreeStyle/zTreeStyle.css" type="text/css"></link>
 	<script type="text/javascript" src="${path}/style_lib/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
 	<script type="text/javascript" src="${path }/style/js/chkie.js"></script>
 	<jsp:include page="/WEB-INF/jsp_lib/my97.jsp"/>
	<script type="text/javascript">
		function zTreeOnClick(event, treeId, treeNode, clickFlag) {
		   	$("input[name='bank_id']").val(treeNode.id);
		   	$("#form1").submit();
		};
		function add_and_edit(param_url){
			$.ajax({
				type:"post",
				url:param_url,
				success:function(html){
					$("#add_edit_form").html(html);
				}
			});
		}
	 	var setting = {
	 			edit: {enable: false},
	 			view: {fontCss : {"margin": "2px"}},
				data: {
					simpleData: {
						enable: true,
						idKey:'_id',
						pIdKey:'super_id',
						rootPId:'root'
					}
				},
				callback: {
					onClick: zTreeOnClick
				}
			};
		var zNodes = $.parseJSON('${bankJson}');
		var zTreeObj;
		$(function(){
			$.each(zNodes,function(i,n){
				zNodes[i].iconOpen="${path}/style_lib/zTree_v3/icon/open.jpg";
				zNodes[i].iconClose="${path}/style_lib/zTree_v3/icon/close.jpg";
				zNodes[i].icon="${path}/style_lib/zTree_v3/icon/open.jpg";
				
				zNodes[i].id=zNodes[i]._id;
				
				if(getExplorer()=="no"){
					$("#add_edit_form").attr("style","margin-left: 310px;")
				}
			});
			
			zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
			zTreeObj.expandAll(false);
			
			var zTree = $.fn.zTree.getZTreeObj("treeDemo");
			zTree.selectNode(zTree.getNodeByParam("id", '${bank_id}'));
		});
		function query(){
			$("#form1").submit();
		}
		function myAdd_form(){
			var bank_id = $("input[name='bank_id']").val();
			var url = "${path}/ix/mac/wktime/add_form.htm?bank_id="+bank_id;
			add_and_edit(url);
		}
		function myEdit_form(wktime_id){
			var url = "${path}/ix/mac/wktime/edit_form.htm?wktime_id="+wktime_id;
			add_and_edit(url);
		}
		function myDel(wktime_id){
			var url = "${path}/ix/mac/wktime/del.htm?wktime_id="+wktime_id;
			$("#form1").attr("action",url);
			$("#form1").submit();
		}
	</script>
</head>
<body>
	<jsp:include page="/WEB-INF/jsp_lib/tip.jsp" />
	<input name='bank_id' value='${bank_id}' type="hidden"/>
	<div class="row-fluid">
	<div style="float: left;width:300px;overflow:auto;" >
		<div class="w-box" style="width:300px;">
			<h2 style="border-bottom:solid 1px #B1E6EC;"><div>
				所有机构
			</div></h2>
			<div class="zTreeDemoBackground left" style="height:450px;300px;overflow:auto;border:solid 1px #B1E6EC;border-top-width: 0px;">
				<ul id="treeDemo" class="ztree"></ul>
			</div>
		</div>
	</div>
	<form action="${path}/ix/mac/wktime/list.htm" id="form1" method="post">
		<input name="bank_id" value="${bank_id }" type="hidden"/>
		<div id="add_edit_form" style="float:left;margin-left: 10px;">
			<h2>
				<div>印控仪特殊工作时间设置</div>
			</h2>
			
			<table width="100%" class="listlindex">
				<tr>
					<th>机构</th>
					<th>开始日期</th>
					<th>结束日期</th>
					<th>开始时间</th>
					<th>结束时间</th>
					<th>录入人员</th>
					<th>操作</th>
				</tr>
				<c:if test="${fn:length(list)==0}">
					<tr>
						<td colspan="7"><div class="tip_div">暂无记录.</div></td>
					</tr>
				</c:if>	
				<c:forEach items="${list}" var="v">					
					<tr>
						<td>${v.name}</td>
						<td>${v.start_date}</td>
						<td>${v.end_date}</td>
						<td>${v.start_time}</td>
						<td>${v.end_time}</td>
						<td>${v.uname}</td>
						<td>
							<a href="javascript:myDel('${v._id}');">【删除】</a>	
							<a href="javascript:myEdit_form('${v._id}');">【修改】</a>	
						</td>
						
					</tr>
				</c:forEach>
			</table>	
			<div id="response"></div>
			<div class="options" style="height: 20px;">
				<c:if test="${bank_id!=null }"><p><a href="javascript:myAdd_form();">【添加】</a></p></c:if>
				<div class="clear"></div>
			</div>
		</div>
	</form>	
	</div>
</body>
</html>
